package cn.edu.gdmec.android.activitylifecycletest;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;

//onCreate(),onStart(),onResume(),onPause(),onStop(),onDestroy()
public class MainActivity extends Activity {
    public static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate ( savedInstanceState );
        Log.d ( TAG, "onCreate" );
        requestWindowFeature ( Window.FEATURE_NO_TITLE );
        setContentView ( R.layout.activity_main );

        Button startNormalActivity = (Button) findViewById ( R.id.start_normal_activity );
        Button startDialogActivity = (Button) findViewById ( R.id.start_dialog_activity );

        startNormalActivity.setOnClickListener ( new View.OnClickListener () {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent ( MainActivity.this, NormalActivity.class );
                startActivity ( intent );
            }
        } );

        startDialogActivity.setOnClickListener ( new View.OnClickListener () {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent ( MainActivity.this, DialogActivity.class );
                startActivity ( intent );
            }
        } );
    }

//    生命活动周期
    @Override
    protected void onStart(){
        super.onStart ();
        Log.d ( TAG, "onStart" );
    }
    @Override
    protected void onResume(){
        super.onResume ();
        Log.d ( TAG, "onResume" );
    }
    @Override
    protected void onPause(){
        super.onPause ();
        Log.d ( TAG, "onPause" );
    }
    @Override
    protected void onStop(){
        super.onStop ();
        Log.d ( TAG, "onStop" );
    }
    @Override
    protected void onDestroy(){
        super.onDestroy ();
        Log.d ( TAG, "onDestroy" );
    }
    @Override
    protected void onRestart(){
        super.onRestart ();
        Log.d ( TAG, "onRestart" );
    }

}
